// src/stores/message.js
import { defineStore } from 'pinia';
import { ref } from 'vue';

export const useMessageStore = defineStore('message', () => {
  const latestMessage = ref('');
  const pushedMessages = ref([]);

  const setLatestMessage = (message) => {
    latestMessage.value = message;
  };

  const addPushedMessage = (message) => {
    pushedMessages.value.push({
      id: Date.now(),
      content: message,
      timestamp: new Date().toLocaleString()
    });
  };

  const clearMessages = () => {
    latestMessage.value = '';
    pushedMessages.value = [];
  };

  return {
    latestMessage,
    pushedMessages,
    setLatestMessage,
    addPushedMessage,
    clearMessages
  };
});